﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DnPakExplorer.Controls {
	public partial class BagControl : BagControlBase {

		private List<ToggleButtonOption> mToggleGroup;

		public BagControl() {
			InitializeComponent();
			mToggleGroup = new List<ToggleButtonOption>();
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleAll, filter = null});
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleButtonCashEquip, filter = new CashItemFilter()});
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleButtonEquip, filter = new  NormalItemFilter()});
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleGlyph, filter = new ItemFilter(ItemType.SkillGlyph, ItemType.SpecialSkillGlypgh) });
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleDragonJewel, filter = new ItemFilter(ItemType.DragonJewel, ItemType.SkillDragonJewel) });
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleOther, filter = null });
			mToggleGroup.Add(new ToggleButtonOption() { button = toggleTailsman, filter = new ItemFilter(ItemType.Tailsman) });
		}

		private void toggleButton_OnToggleChanged(object sender, EventArgs e) {
			ToggleButton btn = sender as ToggleButton;
			if (btn != null && btn.IsOn) {
				for (int i=0; i<mToggleGroup.Count; i++) {
					if (ReferenceEquals(btn, mToggleGroup[i].button)) {
						SetFilter(mToggleGroup[i].filter);
					} else {
						mToggleGroup[i].button.IsOn = false;
					}
				}
			}
		}

		public class ToggleButtonOption {
			public ToggleButton button;
			public IBagItemFilter filter;
		}

		private void OnBtnLeftPage(object sender, EventArgs e) {

		}

		private void OnBtnRightPage(object sender, EventArgs e) {

		}

		private void textBoxWraper1_TextBox_TextChanged(object sender, EventArgs e) {
			TextBox text = sender as TextBox;
			if (text != null)
				SetFilterString(text.Text);
		}
	}
}
